import java.io.*;

public class ConvertStreamDemo01 {
    public static void main(String[] args) throws IOException {

        OutputStreamWriter otw = new OutputStreamWriter(new FileOutputStream("MyFile\\src\\tmp\\test.txt"),"UTF-8");
        otw.write("Hello    \n");
        otw.write("World  \n");
        otw.flush();   //刷新流
        otw.write("中国 \n");
        otw.close();

        InputStreamReader isr = new InputStreamReader(new FileInputStream("MyFile\\src\\tmp\\test.txt"),"UTF-8");
        char[] chs = new char[1024];
        int len;
        while((len = isr.read(chs)) != -1){
            System.out.println(new String(chs,0,len));
        }
        isr.close();

    }
}
